package com.shxs.model.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 小说对象 novel_table
 * 
 * @author ruoyi
 * @date 2024-05-31
 */
public class NovelTable
{
    private static final long serialVersionUID = 1L;

    /** $column.columnComment */
    private Long novelId;

    /** $column.columnComment */

    private Long userId;

    /** $column.columnComment */

    private String novelName;

    /** $table.subTable.functionName信息 */
    private List<VoiceRoleTable> voiceRoleTableList;

    public void setNovelId(Long novelId) 
    {
        this.novelId = novelId;
    }

    public Long getNovelId() 
    {
        return novelId;
    }
    public void setUserId(Long userId) 
    {
        this.userId = userId;
    }

    public Long getUserId() 
    {
        return userId;
    }
    public void setNovelName(String novelName) 
    {
        this.novelName = novelName;
    }

    public String getNovelName() 
    {
        return novelName;
    }

    public List<VoiceRoleTable> getVoiceRoleTableList()
    {
        return voiceRoleTableList;
    }
    public Map<String,String> getVoiceRoleTableListAsMap(){
        Map<String,String> map = new HashMap<>();
        for(VoiceRoleTable role:voiceRoleTableList)
        {
            map.put(role.getRoleName(), role.getModelName());
        }
        return map;
    }
    public void setVoiceRoleTableList(List<VoiceRoleTable> voiceRoleTableList)
    {
        this.voiceRoleTableList = voiceRoleTableList;
    }

    public void setVoiceRoleTableListByMap(Map<String,String> voiceRole){
        voiceRoleTableList=new ArrayList<>();
        VoiceRoleTable roleTable ;
        for (Map.Entry<String,String> entry : voiceRole.entrySet()) {
            roleTable = new VoiceRoleTable();
            roleTable.setRoleName(entry.getKey());
            roleTable.setModelName(entry.getValue());
            roleTable.setNovelId(novelId);
            voiceRoleTableList.add(roleTable);
        }
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("novelId", getNovelId())
            .append("userId", getUserId())
            .append("novelName", getNovelName())
            .append("voiceRoleTableList", getVoiceRoleTableList())
            .toString();
    }
}
